package top.tony.base.pagenation;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by Tony_Du on 2015/12/3 0003.
 */
public abstract class BaseQueryObject {
    private int pageNo;
    private int pageSize;

    private boolean built=false;
    protected StringBuilder selectSql=new StringBuilder();
    protected StringBuilder countSql=new StringBuilder();
    protected Map<String,Object> param=new HashMap<String, Object>();
    protected abstract void buildSql();

    public int getPageNo() {
        return pageNo;
    }

    public void setPageNo(int pageNo) {
        this.pageNo = pageNo;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public StringBuilder getSelectSql() {
        init();
        return selectSql;
    }

    public StringBuilder getCountSql() {
        init();
        return countSql;
    }

    public Map<String, Object> getParam() {
        init();
        return param;
    }

    private void init(){
        if(!built){
            buildSql();
            built=true;
        }
    }
}
